
 
                             S P E C F U N


                       A Special Functions Library 

                         for the HP48 with ALG48


                               Version 3.0



       (c) 1994,95 by Mika Heiskanen and Claude-Nicolas Fiechter



1. ACKNOWLEDGEMENTS, COPYRIGHT & DISCLAIMER OF WARRANTY
=======================================================

All the files of the SpecFun and ALG48 libraries are copyrighted (c) 
by Claude-Nicolas Fiechter and Mika Heiskanen. 

SpecFun is distributed in the hope that it will be useful, but the
COPYRIGHT HOLDERS PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. IN NO EVENT WILL THE COPYRIGHT HOLDERS BE LIABLE TO YOU FOR
DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM.

This version of SpecFun is a GiftWare release. You may use it as long as
you like, but only for non-commercial purposes and only as a private
person. Permission to copy the whole, unmodified, SpecFun library is
granted provided that the copies are not made or distributed for resale
(excepting nominal copying fees) and provided that you conspicuously and
appropriately include on each copy this copyright notice and disclaimer
of warranty.

Special thanks to Dr. Mark A. Ordal whose Bessel function implementations
were the basis for the ones in SpecFun.


2. OVERVIEW
===========

SpecFun defines a number of commonly used "special functions" not
provided by the HP48, including Bessel functions, error functions, Gamma
and Beta functions, and polynomial generating functions.  Polynomial
generating functions include Legendre, Hermite, Tschebyscheff and
Laguerre polynomials as well as spherical harmonics.

SpecFun works in conjunction with the ALG48 library (c) by
Claude-Nicolas Fiechter and Mika Heiskanen and needs ALG48 to be
installed to work properly.  The function names in SpecFun were chosen
so as to be displayed in the customary way when using the EQSTK library
(c) by the same authors.


3. INSTALLATION
===============

SpecFun takes approximately 6Kb of memory and works in both HP48G(X) and
HP48S(X).  SpecFun uses some of the internal subroutines in ALG48, and
thus requires it to be installed.  See the ALG48 documentation for 
information on installing ALG48.

Due to the special optimization features used in ALG48, not all storage
combinations are allowed. The following ones are possible:

  - In SX there are no restrictions
  - In GX if ALG48 is in port 0 or port 1 then SpecFun
    can be stored in any port.
  - In GX if ALG48 is stored in port 2 (or higher) then
    SpecFun must be stored in the same port, or port 0.

Installing ALG48 and SpecFun in the same port seems the most natural
choice and is highly recommended. 

SpecFun is an auto-attaching library (library number 911). To install it
on your HP48 download the file "specfun.lib" onto your calculator (in
BINARY mode), put the content of the created variable on the stack,
store it the port of your choice (e.g., 'SPECFUN.LIB' DUP RCL SWAP 
PURGE 0 STO) and power-cycle the calculator.


4. USE
======

The functions defined by SpecFun are divided in two groups: special
functions and polynomial generating functions.  We give below the
definitions of all the functions implemented in SpecFun.  Section 4.3
gives some example of utilization.


4.1 Special Functions
---------------------

The special functions accept all combinations of real and symbolic
arguments, but are evaluated only for real arguments.  To evaluate the
Bessel functions the order argument 'n' has to be an integer value,
otherwise an "Undefined Result" error is generated.


* Gamma Function

              inf
              /  -t x-1
  GAMMA(x) =  | e  t   dt , x>0
              /
              0

* Beta Function

              1
              /  x-1     y-1     GAMMA(x)GAMMA(y)
  BETA(x,y) = | t   (1-t)   dt = ---------------- , x>0, y>0
              /                     GAMMA(x+y)
              0

* Error Functions

              x    2
           2  /  -t
  ERF(x) = -- | e  dt
           PI /
              0

               inf  2
            2  /  -t
  ERFC(x) = -- | e  dt = 1 - ERF(x)
            PI /
               x


* Bessel Functions


                     inf      r     n+2r
                     ---  (-1) (x/2)
  J.n(n,x) = J (x) = >   ----------------
              n      ---  r! GAMMA(n+r+1)
                     r=0

                          J (x)cos(p*PI)-J (x)
                           p              -p
  Y.n(n,x) = Y (x) = LIM  -------------------- , x>=0
              n      p->n      sin(p*PI)


                      -n
  I.n(n,x) = I (x) = i  J (ix)
              n          n

                          I (x) - I (x)
                           -p      p     Pi
  K.n(n,x) = K (x) = LIM  ------------- ---- , x>=0
              n      p->n   sin(p*PI)     2


* Quick access commands

  J.0(x) = J.n(0,x)
  J.1(x) = J.n(1,x)


4.2 Polynomial Generating Functions
-----------------------------------

The polynomial generating functions expect the order arguments (n,m)
to be positive integer values and the variables (x,a,b) to be symbolic 
or identifier objects.  A simplified output form is used for the Legendre
polynomials when the variable argument is of the form 'cos(x)', for some
arbitrary sub-expression x (see Section 4.3).
 

* Legendre Polynomials

                             n
                       1    d     2      n
  P.n(n,x) = P (x) = ----- --- ( x  - 1 )
              n       n      n
                     2  n! dx

                                    m
                 m          2 m/2  d
  P.nm(n,m,x) = P (x) = (1-x )    --- P (x)
                 n                  m  n
                                  dx


* Spherical Harmonics

                                   ------------
                   m            m |(2n+1)(n-m)!  m        imb
  Y.nm(n,m,a,b) = Y (a,b) = (-1)  |------------ P (cos a)e
                   n             \| 4pi (n+m)!   n


* Hermite Polynomials

                            x^2       -x^2
                            ---   n   ----
                         n   2   d      2
  H.n(n,x) = H (x) = (-1)  e    ---  e
              n                   n
                                dx

* Tschebyscheff Polynomials


  T.n(n,x) = T (x) = Cos[n*ArcCos(x)]
              n   

                     Sin[(n+1)ArcCos(x)]
  U.n(n,x) = U (x) = -------------------
              n         Sqrt[1-x^2]


* Laguerre Polynomials

                     x   n
                    e   d    n  -x
  L.n(x) = L (x) = --- --- (x  e  )
            n       n!   n
                       dx

                            m
             m          m  d
  L.nm(x) = L (x) = (-1)  --- L  (x)
             n              m  n+m
                          dx


4.3 Examples
------------

                      1    5    3
  5 X P.n =>          -(63X -70X +15X)               Standard output form
                      8

                              2 1/2
  2 1 X P.nm =>       3*X*(1-X )                     Standard output form


  2 1 COS(x) P.nm =>  3*COS(X)*SIN(X)                Special output for cos(x)

                       _____
                      |  5                 ip
  2 1 t p Y.nm =>  -  |-----*3COS(t)SIN(t)e          Usually t,p = theta, phi
                     \|24*PI


                           5          3
  5 COS(X) T.n => 16*COS(X) -20*COS(X) +5*COS(X)     Expansion of cos(5x)



5. CHANGES FROM PREVIOUS VERSIONS
=================================

5.1 Changes from version 2.4 to 3.0
-----------------------------------

- Removed infinite precision factorial command.
- Extended Bessel function ranges to x<0 and n<0 when possible.
- Allowed m>n for polynomial generating functions.


6. CONTACT
==========

Gifts :), bug reports, and constructive comments and suggestions 
can be addressed to

 Mika Heiskanen
 Jamerantaival 7 C 355
 02150 Espoo
 Finland

 e-mail: mheiskan@delta.hut.fi

or to 

 Claude-Nicolas Fiechter
 Department of Computer Science
 University of Pittsburgh
 Pittsburgh, PA 15260, U.S.A.

 e-mail: fiechter@cs.pitt.edu

